package org.csu.equipment.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.csu.equipment.entity.Warehouse;
import org.csu.equipment.persistence.WarehouseMapper;
import org.csu.equipment.service.WarehouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class WarehouseServiceImpl implements WarehouseService {

    @Autowired
    private WarehouseMapper warehouseMapper;

    @Override
    public void addQuantity(String type, int addQ) {
        Warehouse warehouse = (Warehouse)warehouseMapper.selectById(type);
        warehouse.setQuantity(warehouse.getQuantity()+addQ);
        warehouseMapper.updateById(warehouse);
    }

    @Override
    public void subQuantity(String type, int subQ) {
        Warehouse warehouse = (Warehouse)warehouseMapper.selectById(type);
        warehouse.setQuantity(warehouse.getQuantity()-subQ);
        warehouseMapper.updateById(warehouse);
    }
}
